package com.qf.spring.advice;

import org.springframework.aop.AfterAdvice;
import org.springframework.aop.AfterReturningAdvice;
import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.aop.ThrowsAdvice;

import java.lang.reflect.Method;

/**
 * 前置通知,后置通知~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */
public class TranAdvice implements MethodBeforeAdvice , AfterReturningAdvice  {
    /**
     * 在我们目标方法执行之前先执行，相当于我们web中filter在方形之前的代码
     * @param method
     * @param args
     * @param target
     * @throws Throwable
     */
    @Override
    public void before(Method method, Object[] args, Object target) throws Throwable {
        System.out.println("事务开启了++++++++++++");
    }

    @Override
    public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {

        System.out.println( "返回值为"+returnValue+"+++++++++++++++++++++++++++");

    }
}
